const fp = require('lodash/fp');
const {Container, Maybe} = require('./support.js');

// test1
let maybe = Maybe.of([5, 6, 1]);
let ex1 = (y)=>{
    return maybe.map(fp.map((x)=>fp.add(x,y)));
}
// let result = ex1(1);
// console.log(result._value);

// test 2
let xs = Container.of(['do', 'ray', 'me']);
let ex2 = ()=>{
    return xs.map(fp.first);
}
// console.log(ex2()._value)

// test 3
let safePorp = fp.curry(function(x, o){
    return Maybe.of(o[x]);
})
let user = {id: 2, name: 'Albert'};
let ex3 = ()=>{
    return safePorp('name', user).map(fp.first);
}
// console.log(ex3()._value);

// test 4
let ex4 = function(n){
    // if(n){
    //     return parseInt(n);
    // }
    let maybe = Maybe.of(n);
    return maybe.map(parseInt);
}
